package com.linsir.file.service;

import com.linsir.file.dto.UploadFileResult;
import com.linsir.file.entity.UploadFile;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;

//import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;

/**
 * @ProjectName: linsir
 * @Package: com.linsir.file.service
 * @ClassName: FileStorageService
 * @Description: 文件操作接口$
 * @Author:Linsir
 * @CreateDate: 2022/9/15 12:57
 * @UpdateDate: 2022/9/15 12:57
 * @Version: 0.0.1$
 */
public interface FileStorageService {


    /**
     * @Author linsir
     * @Description 存储文件，并不写入到数据库中
     * @Date 13:07 2022/9/15
     * @Param [file]
     * @return com.linsir.file.dto.UploadFileResult
     **/
    UploadFileResult storage(MultipartFile file) throws Exception;


    /**
     *  流分方式
     * @param inputStream
     * @param fileName
     * @return
     * @throws Exception
     */
    UploadFileResult storage(InputStream inputStream, String fileName) throws Exception;

    /**
     * 获取文件
     *
     * @param filePath 文件路径
     * @return
     * @throws Exception
     */
    InputStream getFile(String filePath) throws Exception;

    /**
     * 获取文件
     *
     * @param uploadFile
     * @param response
     * @return
     * @throws Exception
     */
    void download(UploadFile uploadFile, HttpServletResponse response) throws Exception;

    /**
     * 删除文件
     *
     * @param filePath 文件路径
     * @return 是否删除成功
     */
    boolean delete(String filePath);

}
